//  https://www.luogu.com.cn/problem/P5731

#include<iostream>
using namespace std;

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
const int N = 10;

int main()
{
	int arr[N][N] = { 0 };
	int a = 1, b = 1; //
	int n = 0;
	cin >> n;
	int cnt = 1;
	int pos = 0;

	while (cnt <= n * n)
	{
		arr[a][b] = cnt;
		int x = a + dx[pos], y = b + dy[pos];

		if (x > n || x < 1 || y>n || y < 1 || arr[x][y])
		{
			pos = (pos + 1) % 4;
			x = a + dx[pos], y = b + dy[pos];
		}
		a = x, b = y;
		cnt++;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= n;j++)
		{
			printf("%3d", arr[i][j]);
		}
		cout << endl;
	}
	return 0;
}